package io.renren.modules.generator.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.WebAdministratorDao;
import io.renren.modules.generator.entity.WebAdministratorEntity;
import io.renren.modules.generator.service.WebAdministratorService;


@Service("webAdministratorService")
public class WebAdministratorServiceImpl extends ServiceImpl<WebAdministratorDao, WebAdministratorEntity> implements WebAdministratorService {

    @Autowired
    private WebAdministratorDao webAdministratorDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        IPage<WebAdministratorEntity> page = this.page(
                new Query<WebAdministratorEntity>().getPage(params),
                new QueryWrapper<WebAdministratorEntity>().like(StringUtils.isNotBlank(key),"admin_name",key)
        );

        return new PageUtils(page);
    }

    @Override
    public Integer getMaxSort() {
        Integer integer = webAdministratorDao.queryMaxSort();
        return integer;
    }

}